Skip to content

Profiling example #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Profiling example #4

wants to merge 9 commits into from

Conversation

rogerkuou
Copy link
Contributor

@rogerkuou rogerkuou commented May 2, 2025

Set up experiments for profiling, as required in https://github.com/TUDelftGeodesy/DePSI_group/issues/88

@rogerkuou rogerkuou marked this pull request as ready for review May 13, 2025 08:59
@rogerkuou rogerkuou requested a review from Copilot May 13, 2025 08:59
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR sets up experiments for profiling the Arc Unwrapping algorithm using both loop‐based and Dask-based methods, as described in issue #88. Key changes include:

  • Adding a Dask-based unwrapping implementation (both script and notebook versions) to leverage parallel processing.
  • Including a loop-based unwrapping implementation (script and notebook) for baseline comparison.
  • Updating documentation in the README to describe profiling procedures and commands.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
profiling_example/lambda_unwrap_dask.py Adds a Dask-based parallel unwrapping script with process‐based scheduling.
profiling_example/lambda_unwrap_dask.ipynb Introduces a Jupyter notebook for debugging/visualizing the Dask-based implementation.
profiling_example/lambda.py Provides a loop-based unwrapping script for direct unwrapping execution.
profiling_example/lambda.ipynb Contains a notebook version of the loop-based unwrapping method for analysis.
profiling_example/README.md Updates documentation to explain profiling experiments using both approaches.

@rogerkuou
Copy link
Contributor Author

Hi @fnattino, in this PR I setup the profiling experiment.

The explaination of the files should be in README, including a link to the results. I put the discussion of the results in this discussion channel .

Can you review on the profiling method? Thanks

@rogerkuou rogerkuou requested a review from fnattino May 13, 2025 10:13
Copy link

@fnattino fnattino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rogerkuou, looks good! I think the instructions on how to setup the profiler are very clear.

Only very small suggestions from my side, the main one being that the pyspy-speedscope outputs are in JSON format.

With respect to the results of the benchmark, maybe it is not surprising that the Dask implementation essentially does not give any improvement.

The initial benchmark seems to suggest a lot of time is spent as overhead in small np call. With the for loop and most of the time being spent within the Python interpreter (i.e. not within numpy functions, which release the GIL) the threading approach cannot give any benefit. Not sure about the processing approach, but it probably suffers from the overhead of the data being transferred from the main process to the workers and back..

py-spy record --output profile_loop_60pnts --idle --rate 5 --subprocesses --format speedscope python lambda_unwrap.py
```

### Dask with `processes` schedular:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Dask with `processes` schedular:
### Dask with `processes` scheduler:

py-spy record --output profile_dask_60pnts_processes --idle --rate 5 --subprocesses --format speedscope python lambda_unwrap_dask.py
```

### Dask with `threads` schedular:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Dask with `threads` schedular:
### Dask with `threads` scheduler:

### Loop method

```sh
py-spy record --output profile_loop_60pnts --idle --rate 5 --subprocesses --format speedscope python lambda_unwrap.py

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
py-spy record --output profile_loop_60pnts --idle --rate 5 --subprocesses --format speedscope python lambda_unwrap.py
py-spy record --output profile_loop_60pnts.json --idle --rate 5 --subprocesses --format speedscope python lambda_unwrap.py

```

```sh
py-spy record --output profile_dask_60pnts_processes --idle --rate 5 --subprocesses --format speedscope python lambda_unwrap_dask.py

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
py-spy record --output profile_dask_60pnts_processes --idle --rate 5 --subprocesses --format speedscope python lambda_unwrap_dask.py
py-spy record --output profile_dask_60pnts_processes.json --idle --rate 5 --subprocesses --format speedscope python lambda_unwrap_dask.py

```

```sh
py-spy record --output profile_dask_60pnts_threads --idle --rate 5 --subprocesses --format speedscope python lambda_unwrap_dask.py

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
py-spy record --output profile_dask_60pnts_threads --idle --rate 5 --subprocesses --format speedscope python lambda_unwrap_dask.py
py-spy record --output profile_dask_60pnts_threads.json --idle --rate 5 --subprocesses --format speedscope python lambda_unwrap_dask.py

py-spy record --output profile_dask_60pnts_threads --idle --rate 5 --subprocesses --format speedscope python lambda_unwrap_dask.py
```

Then you can visualize the profile using the [`speedscope` web tool](https://www.speedscope.app/)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Then you can visualize the profile using the [`speedscope` web tool](https://www.speedscope.app/)
Then you can visualize the profiling results using the [`speedscope` web tool](https://www.speedscope.app/) by uploading the corresponding JSON file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants